package com.netrust.cmsx.entity.module.sys;

import static javax.persistence.GenerationType.IDENTITY;

import java.sql.Timestamp;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.netrust.cmsx.entity.module.cms.AttachArticle;

/**
 * 文件附件类
 * @CopyRight：http://www.netrust.cn/
 *
 * @Description   
 * @Author lazite 
 * @CreateTime 2016年11月19日 下午2:06:16   
 * @ModifyBy lazite 
 * @ModeifyTime 2016年11月19日 下午2:06:16   
 * @ModifyDescription
 * @Version   V1.0
 */
/**
 * @author Administrator
 *
 */
@Entity
@Table(name = "t_attach")
public class Attach {
	private Integer id;
	private String uuid;
	private Integer type;
	private String originalName;// 原始文件名称
	private String targetName;// 存储文件名称
	private String targetUrl;// 存储文件路径
	private String cover;// 封面
	private String suffix;// 文件后缀
	private String compressUrl;// 压缩文件路径【仅对图片保存该路径】
	private Timestamp uploadTime;// 上传时间
	private String remark;// 备注
	private String originalSize;// 原始文件大小

	private String originalVolume;// 原始文件尺寸大小【长*宽】
	private String targetVolume;// 存储文件尺寸大小【长*宽】

	@JsonIgnore
	private List<AttachArticle> attachArticles;

	public Attach() {
		super();
	}

	public Attach(Integer id) {
		super();
		this.id = id;
	}

	public Attach(Integer id, String uuid, Integer type, String originalName, String targetName, String targetUrl,
			String cover, String suffix, String compressUrl, Timestamp uploadTime, String remark, String originalSize) {
		super();
		this.id = id;
		this.uuid = uuid;
		this.type = type;
		this.originalName = originalName;
		this.targetName = targetName;
		this.targetUrl = targetUrl;
		this.cover = cover;
		this.suffix = suffix;
		this.compressUrl = compressUrl;
		this.uploadTime = uploadTime;
		this.remark = remark;
		this.originalSize = originalSize;
	}
	
	public Attach(Integer id, String uuid, Integer type, String originalName, String targetName, String targetUrl,
			String cover, String suffix, String compressUrl, Timestamp uploadTime, String remark, String originalSize,
			String originalVolume, String targetVolume) {
		super();
		this.id = id;
		this.uuid = uuid;
		this.type = type;
		this.originalName = originalName;
		this.targetName = targetName;
		this.targetUrl = targetUrl;
		this.cover = cover;
		this.suffix = suffix;
		this.compressUrl = compressUrl;
		this.uploadTime = uploadTime;
		this.remark = remark;
		this.originalSize = originalSize;
		this.originalVolume = originalVolume;
		this.targetVolume = targetVolume;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "a_id", unique = true, nullable = false)
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "a_uuid", nullable = false, unique = true)
	public String getUuid() {
		return uuid;
	}

	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	@Column(name = "a_type")
	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	@Column(name = "a_original_name")
	public String getOriginalName() {
		return originalName;
	}

	public void setOriginalName(String originalName) {
		this.originalName = originalName;
	}

	@Column(name = "a_target_name")
	public String getTargetName() {
		return targetName;
	}

	public void setTargetName(String targetName) {
		this.targetName = targetName;
	}

	@Column(name = "a_target_url", nullable = false)
	public String getTargetUrl() {
		return targetUrl;
	}

	public void setTargetUrl(String targetUrl) {
		this.targetUrl = targetUrl;
	}

	@Column(name = "a_cover", nullable = false)
	public String getCover() {
		return cover;
	}

	public void setCover(String cover) {
		this.cover = cover;
	}

	@Column(name = "a_suffix")
	public String getSuffix() {
		return suffix;
	}

	public void setSuffix(String suffix) {
		this.suffix = suffix;
	}

	@Column(name = "a_compress_url")
	public String getCompressUrl() {
		return compressUrl;
	}

	public void setCompressUrl(String compressUrl) {
		this.compressUrl = compressUrl;
	}

	@Column(name = "a_upload_time", nullable = false)
	public Timestamp getUploadTime() {
		return uploadTime;
	}

	public void setUploadTime(Timestamp uploadTime) {
		this.uploadTime = uploadTime;
	}

	@JsonIgnore
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "attach")
	public List<AttachArticle> getAttachArticles() {
		return attachArticles;
	}

	@JsonIgnore
	public void setAttachArticles(List<AttachArticle> attachArticles) {
		this.attachArticles = attachArticles;
	}

	@Column(name = "a_remark", nullable = true)
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name = "a_original_size", nullable = true)
	public String getOriginalSize() {
		return originalSize;
	}

	public void setOriginalSize(String originalSize) {
		this.originalSize = originalSize;
	}

	@Column(name = "a_original_volume", nullable = true)
	public String getOriginalVolume() {
		return originalVolume;
	}

	public void setOriginalVolume(String originalVolume) {
		this.originalVolume = originalVolume;
	}

	@Column(name = "a_target_volume", nullable = true)
	public String getTargetVolume() {
		return targetVolume;
	}

	public void setTargetVolume(String targetlVolume) {
		this.targetVolume = targetlVolume;
	}

	@Override
	public String toString() {
		return "Attach [id=" + id + ", uuid=" + uuid + ", type=" + type + ", originalName=" + originalName
				+ ", targetName=" + targetName + ", targetUrl=" + targetUrl + ", cover=" + cover + ", suffix=" + suffix
				+ ", compressUrl=" + compressUrl + ", uploadTime=" + uploadTime + "]";

	}

}
